// import React, { Component } from 'react';
// import { BrowserRouter, Switch, Route, Link, useRouteMatch, useParams } from 'react-router-dom';

//designer.js
import React, { Component } from 'react';
import {Layout, Button, Tooltip ,Select,Input,Row, Col} from 'antd';
import '../App.css';
import { ExportOutlined,RollbackOutlined,FundViewOutlined
} from '@ant-design/icons';
import WorkbookView from '../pages/model/workbookView'

import '../pages/webExcel.css'
const { Header, Content, Footer } = Layout;
const { Option } = Select;

export default class ViewReport extends Component {

    workbookViewRef=(ref)=>{
        this.workbookView = ref
    }

    //保存表
    exportXls=()=>{
        let _way=this.props.match.params.way;
        let _report_id=this.props.match.params.reportInstanceId

        if(_way==0){

            const url = "/reportapi/report/running/exportData?id="+_report_id;
            window.open(url);

        }

        //this.workbook.saveTable(_report_id);
    }
    goBack=()=>{
        window.history.back()
    }


    render() {

       // console.log(this.props.match.params);
       let _report_id=this.props.match.params.id;
       let _accountSetId=this.props.match.params.accountSetId;
       let _year=this.props.match.params.year;
       let _month=this.props.match.params.month;

        let _orgName=this.props.match.params.orgName;

        let _reportDate=this.props.match.params.reportDate;
        let _reportNo=this.props.match.params.reportNo;
        let _lister=this.props.match.params.lister;
        let _auditor=this.props.match.params.auditor;
        let _way=this.props.match.params.way;
        let _reportInstanceId=this.props.match.params.reportInstanceId;   //财务报表实例id


       console.log("_report_id:"+_report_id+"  ;_accountSetId:"+_accountSetId+";_year:"+_year+";_month:"+_month)

       return (
            <Layout>
                <Content>
                    <div  style={{textAlign:1}}>
                        {/*<h>.....</h>*/}
                    </div>
                    <div>
                        <Tooltip title="export xls">
                            <Button   onClick={this.exportXls} icon={<ExportOutlined/>} />
                        </Tooltip>

                        <Tooltip title="goback">
                            <Button  icon={<RollbackOutlined/>} onClick={() => this.goBack()}/>
                        </Tooltip>
                    </div>
                      <div  style={{position: "relative"}} >
                        <WorkbookView onRef={this.workbookViewRef}
                                      reportId={_report_id}
                                      accountSetId={_accountSetId}
                                      year={_year}
                                      month={_month}
                                      orgName={_orgName}
                                      reportDate={_reportDate}
                                      reportNo={_reportNo}
                                      lister={_lister}
                                      auditor={_auditor}
                                      way={_way}
                                      reportInstanceId={_reportInstanceId}
                        />
                    </div>
                </Content>
                {/*<Footer>Footer</Footer>*/}
            </Layout>

        )
    }
}
